
from multiprocessing import Process, Lock


def f(l,i):
    l.acquire()   # 一把锁
    try:
        print('Hello World', i)
    finally:
        l.release()  # 释放


if __name__ == '__main__':
    lock = Lock()

    for num in range(10):
        Process(target=f, args=(lock, num)).start()
